﻿@model Telecom.Data.CAUHINH_TBI

@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestmCauHinhTb"
    };
}

<script type="text/javascript">

    function opBeginProcess_loading_window_submit() {

        var vSLOT_ADCAUHINH = $('#SLOT_ADCAUHINH').numberspinner('getValue');
        $("#SLOT_ADCAUHINHTB").val(vSLOT_ADCAUHINH);
        var vDAULUONG_ADCAUHINH = $('#DAULUONG_ADCAUHINH').numberspinner('getValue');
        $("#DAULUONG_ADCAUHINHTB").val(vDAULUONG_ADCAUHINH);

        $("#ContentwindowFunction").mask("Dữ liệu đang xử lý");
    }

    function completedAjaxRequestmCauHinhTb(obj) {

        var returnObj = eval('(' + obj.responseText + ')');

        if (returnObj.Status == "success") {


            var $rowReload = $('#lap_thiet_bi_TableContainer').jtable('getRowByKey', $("#THIETBIID_ADCAUHINHTB").val());
            $rowReload.next().find('.jtable-child-table-container').jtable('reload')

            close_window_elements('window_addupdate_cauhinhthietbi');


        } else {

            $("#ContentwindowFunction").unmask();
            confirmOptionNormal(returnObj.Message);
        }

        return false;

    }

    $(document).ready(function () {

        $("#CARD_ADCAUHINH").combobox({
            url: _nameSubDomain + "/TThietbi/ListCard?_tbId=@ViewBag.IDDMTB",
            valueField: "ID",
            textField: "TEN",
            onSelect: function (row) {
                $("#CARD_ADCAUHINHTB").val(row.ID);
                $("#TENCAUHINH_ON_ADD").val(row.TEN + "/" + $('#SLOT_ADCAUHINH').numberspinner('getValue'))
            }

        });

        $('#SLOT_ADCAUHINH').numberspinner({
            min: 1,
            editable: false,
            onChange: function (value) {
                $("#TENCAUHINH_ON_ADD").val($("#CARD_ADCAUHINH").combobox('getText') + "/" + value)
            }
        });

        $('#DAULUONG_ADCAUHINH').numberspinner({
            min: 0,
            editable: false
        });


    });


</script>

@using (Ajax.BeginForm("AddCauHinhTb", "TThietbi", null, ajaxOpts, new { enctype = "multipart/form-data" }))
{
    @Html.HiddenFor(model => model.ID, new { id = "ID_ADCAUHINHTB" })
    @Html.HiddenFor(model => model.THIETBIID, new { id = "THIETBIID_ADCAUHINHTB" })
    @Html.HiddenFor(model => model.CARD, new { id = "CARD_ADCAUHINHTB" })
    @Html.HiddenFor(model => model.SLOT, new { id = "SLOT_ADCAUHINHTB" })
    @Html.HiddenFor(model => model.DAULUONG, new { id = "DAULUONG_ADCAUHINHTB" })
    
    <div id="ContentwindowFunction" class="ContentwindowFunction">
       <table class="tableContentWindowFunction">
           <tr>
                <td>
                   Lắp TB : 
                </td>
               <td>
                    <p>@ViewBag.NameLapTB</p>
               </td>
           </tr>
           <tr>
                <td>
                    Tên : 
                </td>
               <td>
                   @Html.TextBoxFor(model => model.TEN, new { id="TENCAUHINH_ON_ADD", @class = "input_table_function"})
               </td>
           </tr>
           <tr>
                <td>
                   Slot : 
                </td>
               <td>
                    <input class="easyui-numberspinner" value="@Model.SLOT" style="width:450px; height:27px" id="SLOT_ADCAUHINH" name="SLOT_ADCAUHINH">
               </td>
           </tr>
           <tr>
                <td>
                   Card : 
                </td>
               <td>
                   <input class="easyui-combobox" value="@Model.CARD" style="width:450px; height:27px" id="CARD_ADCAUHINH" name="CARD_ADCAUHINH">
               </td>
           </tr>
           <tr>
                <td>
                   Đấu luồng : 
                </td>
               <td>
                    <input class="easyui-numberspinner" value="@Model.DAULUONG" style="width:450px; height:27px" id="DAULUONG_ADCAUHINH" name="DAULUONG_ADCAUHINH">
               </td>
           </tr>
       </table>
        <div style="height:30px"></div>
        <div class="footer_submit" style="margin-top: 10px; text-align: center">
            <button type="submit" onclick="return opBeginProcess_loading_window_submit(); ">
                <span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">Cập nhật cấu hình</span><span class="l-btn-icon icon-add">&nbsp;</span></span>    
            </button>
            <button type="button" onclick="return close_window_elements('window_addupdate_cauhinhthietbi');" >
                <span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">Hủy bỏ</span><span class="l-btn-icon icon-remove">&nbsp;</span></span></button>
        </div>
    </div>
    

}